<template>
  <view class="index">
    <view @tap="toAbout" class="h1">Taro Weapp</view>
    <view>
      <navigator url="/packageA/pages/p-a/index">分包p-a</navigator>
    </view>
    <view>
      <navigator url="/packageA/pages/p-b/index">分包p-b</navigator>
    </view>
    <NumberDisplay/>
    <NumberSubmit/>
    <button @tap="scan">扫码</button>
  </view>
</template>

<script>
import Taro from "@tarojs/taro"
import NumberDisplay from '../../components/NumberDisplay.vue'
import NumberSubmit from '../../components/NumberSubmit.vue'

export default {
  name: 'Index',
  components: {
    NumberDisplay,
    NumberSubmit
  },
  setup() {
    const toAbout = () => {
      console.log("toAbout")
      Taro.navigateTo({
      // Taro.switchTab({
        url: "../about/index?from=index&time="+Date.now()
      })
    }

    const scan = () => {
      Taro.scanCode({
        onlyFromCamera: true,
      }).then(res => {
        Taro.navigateTo({
          url: `../result/index?result=${encodeURIComponent(res.result)}`
        })
        // console.log(res.result)
      })
    }

    return {
      toAbout,
      scan
    }
  }
}
</script>

<style lang="scss">
$h1-color: #ff6700;

.index {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;

  .h1 {
    font-size: 80rpx;
    color: $h1-color;
    background-color: rgba($h1-color, .2);
  }
}
</style>
